Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use non-greedy regex to match a log to fix an error if ngxlog fields are more than pre-defined #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yangchaobj
Copy link

Hi Lebinh
I find an error in matching if my nginx log's fields are more than pre-defined, this error causes ngxtop cannot output any stats result.

My nginx log looks like:
10.18.110.79 - - [31/Mar/2016:14:19:00 +0800] "GET /favicon.ico HTTP/1.1" 200 1406 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0" "-" "yangchao-g.jifen.360.cn" "80" 0.000

after $http_user_agent, I have 3 extra fields.
the current ngxtop matching result is:
{
'remote_addr': '10.18.110.79',
'remote_user': '-',
'time_local': '31/Mar/2016:14:19:00 +0800',
'request': 'GET /favicon.ico HTTP/1.1" 200 1406 "-',
'status': '"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0"',
'body_bytes_sent': '"-"',
'http_referer': 'yangchao-g.jifen.360.cn',
'http_user_agent': '80',
}

you see that the request field eats more bytes than it should.

the fix is to use non-greedy-matching regex.

@yangchaobj yangchaobj changed the title use non-greedy regex to match a log use non-greedy regex to match a log to fix an error if fields are more than predefined Mar 31, 2016
@yangchaobj yangchaobj changed the title use non-greedy regex to match a log to fix an error if fields are more than predefined use non-greedy regex to match a log to fix an error if ngxlog fields are more than pre-defined Mar 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant